<extend name="Layout/ins_page" />
<block name="content">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Form</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
        <script src="/sap/scripts/boot.js" type="text/javascript"></script>
    </head>
    <style>

        td{
            margin-top:10px;

        }
    </style>
    <body>
    <div id="form1" >
        <input name="id" class="mini-hidden"  value="{$data.id}"/>
        <table cellspacing='10' style="width: 700px; border-spacing:0px 10px;" >

            <tr>
                <td>
                    <label for="p_name$text">平台名称：</label>
                </td>
                <td>
                    <input id="p_name"  name="p_name" class="mini-textbox" required="true" width='250px' value ="{$data.p_name}"/>
                </td>
            </tr>

            <!--<tr>-->
                <!--<td>-->
                    <!--<label for="original_name$text">原命名：</label>-->
                <!--</td>-->
                <!--<td>-->
                    <!--<input id="original_name"  name="original_name" class="mini-textbox" width='250px' value ="{$data.original_name}"/>-->
                <!--</td>-->
            <!--</tr>-->

            <!--<tr>-->
                <!--<td>-->
                    <!--<label for="card_code$text">CardCode：</label>-->
                <!--</td>-->
                <!--<td>-->
                    <!--<input id="card_code"  name="card_code" class="mini-textbox" required="true" width='250px' value ="{$data.card_code}"/>-->
                <!--</td>-->
            <!--</tr>-->

            <tr>
                <td>
                    <label for="type$text">平台类型：</label>
                </td>
                <td>
                    <input required="true" id="p_type" name="p_type" class="mini-combobox" style="width:250px;" textField="name" valueField="id" emptyText="请选择平台类型"  url="/SapSupplier/getPlatformType" value=""  allowInput="true" showNullItem="true" nullItemText="请选择平台类型"/>
                </td>
            </tr>

            <tr>
                <td>
                    <label for="type$text">组长：</label>
                </td>
                <td>
                    <input required="true" id="team_leader" name="team_leader" class="mini-combobox" style="width:250px;" textField="emp_no" valueField="emp_no" emptyText="请选择"  url="/SapSupplier/getUserListsByRole/role/4" value=""  allowInput="true" showNullItem="true" nullItemText="请选择"/>
                </td>
            </tr>

            <tr>
                <td>
                    <label for="type$text">经理：</label>
                </td>
                <td>
                    <input id="team_manager" name="team_manager" class="mini-combobox" style="width:250px;" textField="emp_no" valueField="emp_no" emptyText="请选择"  url="/SapSupplier/getUserListsByRole/role/3" value=""  allowInput="true" showNullItem="true" nullItemText="请选择"/>
                </td>
            </tr>

            <tr>
                <td>
                    <label for="type$text">专员：</label>
                </td>
                <td>
                    <input id="team_commissioner" name="team_commissioner" class="mini-combobox" style="width:250px;" textField="emp_no" valueField="emp_no" emptyText="请选择"  url="/SapSupplier/getUserListsByRole/role/2" value=""  allowInput="true" showNullItem="true" nullItemText="请选择"/>
                </td>
            </tr>

            <tr>
                <td>
                    <label for="type$text">助理：</label>
                </td>
                <td>
                    <input id="team_assistant" name="team_assistant" class="mini-combobox" style="width:250px;" textField="emp_no" valueField="emp_no" emptyText="请选择"  url="/SapSupplier/getUserListsByRole/role/1" value=""  allowInput="true" showNullItem="true" nullItemText="请选择"/>
                </td>
            </tr>

            <tr>
                <td>
                    <label for="brand_count$text">品牌数：</label>
                </td>
                <td>
                    <input id="brand_count"  name="brand_count" class="mini-textbox" width='250px'  value ="{$data.brand_count}" vtype="maxLength:30"/>
                </td>
            </tr>

            <tr>
                <td>
                    <label for="category_count$text">品类数：</label>
                </td>
                <td>
                    <input id="category_count"  name="category_count" class="mini-textbox" width='250px'  value ="{$data.category_count}" />
                </td>
            </tr>

            <tr>
                <td>
                    <label for="sku_count$text">SKU数：</label>
                </td>
                <td>
                    <input id="sku_count"  name="sku_count" class="mini-textbox" width='250px'  value ="{$data.sku_count}" vtype="maxLength:11"/>
                </td>
            </tr>



            <tr>
                <td>
                    <label for="online_state$text">上线状态：</label>
                </td>
                <td>
                    <input id="online_state"  name="online_state" class="mini-textbox" width='250px'  value ="{$data.online_state}" />
                </td>
            </tr>

            <tr>
                <td colspan="2">

                    <br/>

                    备注:<input style="width:400px;" name="p_remark" id='p_remark' class="mini-textarea" />
                    <br/><br/>

                </td>

            </tr>

            <tr>
                <td>

                </td>
                <td>

                    <br/>
                    <a class='mini-button' onclick="submitForm(1)" >保存</a>
                    <a class='mini-button' onclick="" >取消</a>
                    <!--CloseWindow()-->

                </td>
            </tr>

        </table>
    </div>
    <script type="text/javascript">

        //去左空格;
        function ltrim(s){
            return s.replace(/(^\s*)/g, "");
        }
        //去右空格;
        function rtrim(s){
            return s.replace(/(\s*$)/g, "");
        }
        //去左右空格;
        function trim(s){
            return s.replace(/(^\s*)|(\s*$)/g, "");
        }

        mini.parse();
        function submitForm(tag) {
            //提交表单数据
            var form = new mini.Form("#form1");
            form.validate();
            if (form.isValid() == false) return;

            //确认提示
            mini.confirm("确定修改记录？", "确定？",
                function (action) {
                    if (action == "ok") {

                        var data = form.getData();      //获取表单多个控件的数据

                        // 去左右空格
                        data.p_name = trim(data.p_name);

                        var json = mini.encode(data);   //序列化成JSON
                        $.ajax({
                            url: "/SapSupplier/doplatformadd",
                            type: "post",
                            data: {data: json},
                            dataType: 'json',
                            success: function (data) {
                                mini.alert(data.msg);
                                //成功后关闭窗口
                                //CloseWindow();
                            }
                        });


                    } else {

                    }
                }
            );

        }

        function CloseWindow(action) {

            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();

            //location.href=document.referrer;
        }


    </script>

    <script type="text/javascript">

        $(document).ready(function() {
            var uploaders = {};
            $('.uploader').each(function() {
                var uploader, $target, $id;
                $target = $(this);
                $id = $target.attr('add_file_id');
                $btn_id = 'btn_' + $id;
                $uploader_id = 'uploader_' + $id;

                settings = {
                    runtimes : 'html5,flash',
                    browse_button : $btn_id, // you can pass in id...
                    container : document.getElementById($uploader_id),
                    url : upload_url,
                    flash_swf_url : app_path + '/Public/Static/plupload/Moxie.swf',
                    filters : {
                        max_file_size : '1000mb'
                    }
                };

                uploader = new plupload.Uploader(settings);
                uploaders[$id] = uploader;

                function FilesAdded(up, files) {

                    for (var i in files) {
                        var str = JSON.stringify(files);

                        if( files[i].id!=null){

                            html = '<li class="tbody" id="' + files[i].id + '">\n';

                            html += '<div class="loading"></div>\n';
                            html += '<div class="data">\n';

                            html += '<span class="del text-center"><a class="link del">删除</a></span>\n';

                            html += '<span class="size text-right">' + plupload.formatSize(files[i].size) + '</span>';
                            html += '<span class="auto autocut">' + files[i].name + '</span>';
                            html += '</li>';
                            html += '</div>\n';

                            $('#uploader_' + $id + ' .file_list').append(html);
                        }
                    }
                    up.start();
                }

                uploader.bind("PostInit", function(up) {
                    if ($(".uploader .tbody").length > 0) {
                        $(".uploader .tbody .loading").css("width", "100%");
                        $(".uploader .thead").show();
                        $(".uploader .tbody").each(function() {
                            id = $(this).attr("filename");
                            filename = $(this).attr("filename");
                            size = $(this).attr("size");
                            file = new plupload.File(id, filename, size);
                            file.status = plupload.DONE;
                            count = uploader.files.length;
                            uploader.files[count] = file;
                            path = 'hhhhhhh';
                        });
                    }
                });

                uploader.init();

                uploader.bind('FilesAdded', FilesAdded);

                uploader.bind("UploadProgress", function(up, file) {
                    $("#" + file.id).find("a.del").hide();
                    $("#" + file.id).find('.loading').css("width", file.percent + "%");
                });

                uploader.bind('FileUploaded', function(up, file, data) {
                    var myObject = eval('(' + data.response + ')');
                    if (myObject.status) {
                        if ($("#add_file_" + $id).length != 0) {
                            $("#add_file_" + $id).val($("#add_file_" + $id).val() + myObject.sid + ";");
                        }
                        $("#" + file.id).attr("add_file", myObject.sid);

                        $new_upload = $("#uploader_" + $id + " .file_list").attr("new_upload");
                        $("#uploader_" + $id + " .file_list").attr("new_upload", $new_upload + myObject.sid + ";");

                        $("#" + file.id).find("a.del").show();
                    } else {
                        ui_alert(myObject.info, function() {
                            $("#" + file.id).remove();
                        });
                    }
                });
            });
        });

        window.onbeforeunload = function(e) {
            e = e || window.event;
            // For IE and Firefox prior to version 4
            $new_upload = $(".file_list").attr("new_upload");
            if ($new_upload !== undefined) {
                if ($new_upload.length) {
                    if (e) {
                        e.returnValue = '上传的附件将被删除，确定退出吗？';
                    }
                    // For Safari
                    return '上传的附件将被删除，确定退出吗？';
                }
            }
        };

        $(document).on("click", ".uploader a.del", function() {
            $obj = $(this).parents("li");
            $uploader = $(this).parents('.uploader');
            ui_confirm("确定要删除吗？", function() {

                $current_del_file = $obj.attr("add_file");
                $(".add_file", $uploader).val($(".add_file", $uploader).val().replace($current_del_file + ";", ""));

                $new_upload = $(".file_list", $uploader).attr("new_upload");
                $(".file_list", $uploader).attr("new_upload", $new_upload.replace($current_del_file + ";", ""));

                $obj.remove();
            });
        });
    </script>

    <script type="text/javascript">
        /* 是否汉字 */
        function isChinese(v) {
            var re = new RegExp("^[\u4e00-\u9fa5]+$");
            if (re.test(v)) return true;
            return false;
        }
        function onChineseValidation(e) {
            if (e.isValid) {
                if (isChinese(e.value) == false) {
                    e.errorText = "必须输入中文";
                    e.isValid = false;
                }
            }
        }
    </script>

    </body>
    </html>

</block>
<block name="js">
    <script type="text/javascript">
        function save() {
            sendForm("form_data", "{:U('save')}", "{:U('index')}");
        }
    </script>
</block>